import { Rule } from "./types";

export const CoroutinesRuleList: Rule[] = [
    {
        id: "GlobalCoroutineUsage",
        descEn: "Report usages of GlobalScope.launch and GlobalScope.async.",
        descCn: "",
        active: false,
        debt: "10min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/coroutines#globalcoroutineusage",
    },
    {
        id: "InjectDispatcher",
        descEn: "Always use dependency injection to inject dispatchers for easier testing.",
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [
            {
                param: "dispatcherNames",
                descEn: "The names of dispatchers to detect by this rule",
                descCn: "",
                defaultValue: ['IO', 'Default', 'Unconfined'],
            }
        ],
        url: "https://detekt.dev/docs/rules/coroutines#injectdispatcher",
    },
    {
        id: "RedundantSuspendModifier",
        descEn: "suspend modifier should only be used where needed, otherwise the function can only be used from other suspending functions. This needlessly restricts use of the function and should be avoided by removing the suspend modifier where it's not needed.",
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/coroutines#redundantsuspendmodifier",
    },
    {
        id: "SleepInsteadOfDelay",
        descEn: "Report usages of Thread.sleep in suspending functions and coroutine blocks. A thread can contain multiple coroutines at one time due to coroutines' lightweight nature, so if one coroutine invokes Thread.sleep, it could potentially halt the execution of unrelated coroutines and cause unpredictable behavior.",
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/coroutines#sleepinsteadofdelay",
    },
    {
        id: "SuspendFunWithCoroutineScopeReceiver",
        descEn: "Suspend functions that use CoroutineScope as receiver should not be marked as suspend. A CoroutineScope provides structured concurrency via its coroutineContext. A suspend function also has its own coroutineContext, which is now ambiguous and mixed with the receiver`s.",
        descCn: "",
        active: false,
        debt: "10min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/coroutines#suspendfunwithcoroutinescopereceiver",
    },
    {
        id: "SuspendFunWithFlowReturnType",
        descEn: "Functions that return Flow from kotlinx.coroutines.flow should not be marked as suspend. Flows are intended to be cold observable streams. The act of simply invoking a function that returns a Flow, should not have any side effects. Only once collection begins against the returned Flow, should work actually be done.",
        descCn: "",
        active: true,
        debt: "10min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/coroutines#suspendfunwithflowreturntype",
    },

];